package com.lihui;

import com.lihui.test.Mobile;
import com.lihui.test.Person;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * 功能描述
 *
 * @author ${USER}
 * @date ${YEAR}/${MONTH}/${DAY}  ${TIME}
 */
public class Main {
    public static void main(String[] args) {
        ApplicationContext context = new AnnotationConfigApplicationContext("com.lihui");
        Person p = (Person) context.getBean("person");
        System.out.println(p);
        System.out.println("================");
        Mobile mobile = (Mobile) context.getBean("mobile");
        System.out.println(mobile);
        System.out.println(p.getMobile());
        System.out.println(p.getMobile() == mobile);
        System.out.println("======================");
        Person p1 = (Person) context.getBean("p1");
        System.out.println(p);
        System.out.println(p1);
        System.out.println(p1 == p);
        Person p2 = (Person) context.getBean("p2");
        System.out.println(p1);
        System.out.println(p2);
        System.out.println(p1 == p2);

//        ApplicationContext contexts = new ClassPathXmlApplicationContext("spring-config.xml");
//        UserController controller = (UserController) contexts.getBean(UserController.class);
//        UserController controller = (UserController) context.getBean("userController");
//        System.out.println(controller.getUser());
        System.out.println("===================");
        Mobile m1 = (Mobile) context.getBean("m");
        System.out.println(m1);

    }
}